//
//  TestModelActorApp.swift
//  TestModelActor
//
//  Created by rolodestar on 2025/6/18.
//

import SwiftUI
import SwiftData

@main
struct TestModelActorApp: App {
    
    var sharedModelContainer: ModelContainer = {
        let schema = Schema([
            Item.self,
            BeautyModel.self,
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

        do {
            return try ModelContainer(for: schema, configurations: [modelConfiguration])
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
    }()
//
//    var store: Store = {
//        let schema = Schema([
//            Item.self,
//            BeautyModel.self,
//        ])
//        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
//
//        do {
//            let container = try ModelContainer(for: schema, configurations: [modelConfiguration])
//            return BeautyModelActor.createShared(container: container)
//        } catch {
//            fatalError("Could not create ModelContainer: \(error)")
//        }
//    }()
    var body: some Scene {
        WindowGroup {
//            ContentView()
            BeautySView()
        }
        .modelContainer(sharedModelContainer)
        .environmentObject(BeautyModelActor(modelContainer: sharedModelContainer))
        .environmentObject(Store(modelContainer: sharedModelContainer))
    }
}
